package com.zijie.hosptal.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.hosptal.pojo.po.Patient;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PatientMapper extends BaseMapper<Patient> {
    default Page<Patient> findList(Page<Patient> patientPage, Patient patient){
        LambdaQueryWrapper<Patient> wrapper = Wrappers.lambdaQuery(patient);
        return selectPage(patientPage,wrapper);
    }
    Patient selectById(Integer id);

    @Select("select id,name,phone from lvyou.patient")
    List<Patient> getAllPatient();

    @Select("select count(1) from lvyou.patient")
    Integer getPatientTotal();

    int updateByPatient(Patient patient);

    @Select("select email,name from lvyou.patient where id=#{patientId}")
    Patient selectByIdToEmain(Integer patientId);
}
